<%= javascript_include_tag "permissions" %>

<div id="destroy_success" class="alert success green rounded-8" style="display: none"></div>

<%= title t(:access_and_permissions) %>

<% form_for @project, :url => bulk_edit_project_permissions_url(@project),
					  :html => {:method => :put, 
								:class => "basic-form rounded large"} do |project_form| %>

	<%= error_messages_for(:project, :associations => :designations, :class => "alert red error rounded-8") %>
	
	<% content_for :javascript do %>
		$(document).ready(function () {		
			$(".add-user-permission").click(function()
			{
				<%= "var permission='#{generate_template(project_form, :designations, :partial => "permission_form")}'" %>
				
				var new_id = new Date().getTime();
				$("#permissions_table > tbody").append(permission.replace(/NEW_RECORD/g, new_id));
				
				return false;
			});		
		});
	<% end %>
	
	<p><%= t :add, :scope => [:permission, :hints] %></p>
	
	<table id="permissions_table" class="basic-table fluid gray-line">
		<thead>
			<tr>
				<th class="left"><%= t :user, :count => 1 %></th>
				<th style="width: 100px"><%= t :admin, :scope => :role, :count => 1 %></th>
				<th style="width: 150px"></th>
			</tr>
		</thead>
		<tfoot>
			<tr class="gray-footer">
				<td class="left" style="padding-top: 5px; padding-bottom: 5px" colspan="10">
					<a href="#" class="awesome gray silver small add-user-permission">
						<span class="icon add">
							<%= t :add, :scope => :permission %>
						</span>
					</a>
				</td>
			</tr>
		</tfoot>
		<tbody>			
			<% project_form.fields_for :designations do |permissions_form| %>
				<%= render :partial => "permission_form", :locals => {:form => permissions_form, :current_user => current_user} %>
			<% end %>			
		</tbody>
	</table>
	
	<button type="submit" class="awesome green silver"><span class="icon tick"><%= t :submit, :scope => :form %></span></button>

<% end %>
	
<% content_for :sidebar do %>
	 <p class="title darkest rounded-4"><%= t :role, :count => 2 %></p>
	 
	 <dl class="icon-list">
	 	<dt class="icon user-admin"><b><%= t :admin, :scope => :role, :count => 2 %></b></dt>
		<dd><%= t :hint, :scope => [:role, :admin] %></dd>
		
		<dt class="icon user"><b><%= t :user, :scope => :role, :count => 2 %></b></dt>
		<dd><%= t :hint, :scope => [:role, :user] %></dd>
	 </dl>
<% end %>
